#include "login.h"
#include "ui_login.h"
#include<QFileDialog>
#include"widget.h"

LogIn::LogIn(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::LogIn)
{
    ui->setupUi(this);
}

LogIn::~LogIn()
{
    delete ui;
}


void LogIn::on_login_clicked()
{
    QString name=ui->lineEdit->text();
    ha.setAddress(ui->address_line->text());
    port=(ui->port_line->text()).toInt();
    ts->connectToHost(ha,port);
    Widget* w=new Widget(ts,name,QPixmap(img));
    ts->write(QString("infotype:initwidget;name:%1;image:%2;").arg(name).arg(img).toUtf8());
    w->setGeometry(100,100,800,800);
    w->show();
    close();

}


void LogIn::on_select_image_clicked()
{
    QString image=QFileDialog::getOpenFileName(this,"",QDir::currentPath());
    img=image;
    ui->image->setPixmap(img);
    ui->image->setScaledContents(true);
}

